﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Creative85.Framework.Data;
using Creative85.Framework.Utilities;
using Project32CHE.Biz.Unionshop.Models;
using NPoco;

namespace Project32CHE.Biz.Unionshop
{
    public static class StorageService
    {
        /// <summary>
        /// 获取店铺下的仓库列表
        /// </summary>
        /// <param name="shopId">店铺Id</param>
        /// <returns>仓库列表</returns>
        public static List<Storage> GetStorage(Guid UnionID, Guid shopId)
        {
            var list = Db.Instance.Query<Storage>().Where(x => (x.ShopID == shopId && x.UnionID == UnionID)).OrderBy(x => x.SortID).ToList();
            var item = list.FirstOrDefault(x => x.IsDefault);
            if (item != null)
            {
                list.Remove(item);
                list.Insert(0, item);
            }
            return list;
        }
    }
}
